// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/elemac/api/DeviceHospitalPointApi'

import OneClass from '@api/elemac/model/DeviceHospitalPointQueryPointAndGraphReq'
import BindClass from '@api/elemac/model/DeviceHospitalPointBindPointAndGraphReq'
import BaseClass from '@api/elemac/model/DeviceHospitalPointDto'
import ChildClass from '@api/elemac/model/DeviceGraphDto'

const CLIENT = CORE.grpcCLIENT(Client)
const BASE = [BaseClass, 'deviceHospitalPointDto']
const CHILDREN = [ChildClass, 'deviceGraphDto', 1]

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 单项 —————————————————————————————— //

  async getOne(one, TIP = '查询系统图') {
    const DTO = CORE.grpcDTO(OneClass, { deviceId: one.id })
    const resp = await CORE.grpc(TIP, CLIENT, 'deviceHospitalPointQueryPointAndGraph', DTO)
    return resp
  },

  // —————————————————————————————— 绑定 —————————————————————————————— //

  async bind(one, TIP = '绑定系统图') {
    const DTO = CORE.grpcDTO(BindClass, one, BASE, CHILDREN)
    await CORE.grpc(TIP, CLIENT, 'deviceHospitalPointBindPointAndGraph', DTO)
    return CORE.grpcOK(TIP)
  },
}
